<script lang="ts" setup>
import {reactive, ref, UnwrapRef } from "vue";
import {
  SearchOutlined,
} from "@ant-design/icons-vue";
import {PIC_REVIEW_STATUS_OPTIONS} from "../constants/picture";


interface FormState {
  layout: 'horizontal' | 'vertical' | 'inline';
  fieldA: string;
  fieldB: string;
}

interface Props {
  onSearch?: (searchForm: API.PictureQueryRequest) => void
}
const props = defineProps<Props>()
const formState: UnwrapRef<FormState> = reactive({
  layout: 'horizontal',
  fieldA: '',
  fieldB: '',
});

// 表格数据相关
const loading = ref(false);

// 搜索条件
const searchParams = reactive<API.PictureQueryRequest>({
  pageSize: 10,
  current: 1,
  sortOrder: 'ascend',
  sortField: 'createTime'
});


// 搜索处理
const doSearch = () => {
  props.onSearch?.(searchParams)
};

</script>

<template>
  <div class="picture-management-container">

    <!-- 搜索区域 -->
    <div class="search-card">
      <div class="search-header">
        <div class="search-gradient"></div>
        <h2 class="search-title">🔍 图片资源管理</h2>
        <p class="search-subtitle">精准定位您的视觉资产</p>
      </div>

      <a-form @finish="doSearch" class="search-form">
        <a-row :gutter="[16, 16]">
          <!-- 搜索项列 -->
          <a-col :xs="24" :sm="12" :md="8" :lg="6">
            <a-form-item label="关键词" class="floating-label">
              <a-input
                  v-model:value="searchParams.searchText"
                  placeholder=" "
                  allow-clear
                  class="neon-input"
              >
                <template #prefix>
                  <SearchOutlined class="input-icon" />
                </template>
              </a-input>
              <label class="input-label">图片名称/描述</label>
            </a-form-item>
          </a-col>


          <a-col :xs="24" :sm="12" :md="8" :lg="6">
            <a-form-item label="类型">
              <a-select
                  v-model:value="searchParams.category"
                  placeholder="选择分类"
                  class="neon-select"
                  allow-clear
              >
                <a-select-option value="nature">自然</a-select-option>
                <a-select-option value="technology">科技</a-select-option>
                <a-select-option value="art">艺术</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12" :md="8" :lg="6">
            <a-form-item label="标签">
              <a-select
                  v-model:value="searchParams.tags"
                  mode="tags"
                  placeholder="添加标签"
                  class="neon-tags"
                  allow-clear
              >
                <a-select-option value="精选">精选</a-select-option>
                <a-select-option value="热门">热门</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12" :md="8" :lg="6">
            <a-form-item label="审核状态">
              <a-select
                  v-model:value="searchParams.reviewStatus"
                  placeholder="选择状态"
                  :options="PIC_REVIEW_STATUS_OPTIONS"
                  class="neon-tags"
                  allow-clear
              />
            </a-form-item>
          </a-col>

          <!-- 搜索按钮 -->
          <a-col :xs="24" :sm="24" :md="24" :lg="24">
            <div class="search-action-wrapper">
              <button class="cybr-btn" type="submit">
                立即搜索
              </button>
            </div>
          </a-col>
        </a-row>
      </a-form>
    </div>

  </div>
</template>

<style scoped lang="less">

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.picture-management-container {
  padding: 2rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  min-height: 100vh;
}

.search-card {
  background: rgba(30, 41, 59, 0.8);
  border-radius: 1.5rem;
  padding: 2rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(99, 102, 241, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);

  .search-header {
    position: relative;
    margin-bottom: 2rem;

    .search-gradient {
      position: absolute;
      top: -50px;
      left: 50%;
      width: 200%;
      height: 200px;
      background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
      transform: translateX(-50%);
      z-index: 0;
    }
    .search-card {
      transition: transform 0.3s ease;
      &:hover {
        transform: translateY(-2px);
      }
    }

    .floating-label {
      position: relative;
      .ant-form-item-label {
        position: absolute;
        top: -8px;
        left: 12px;
        z-index: 1;
        padding: 0 4px;
        background: rgba(30, 41, 59, 0.9);
        transition: all 0.3s ease;
      }

      .input-label {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: #94a3b8;
        pointer-events: none;
        transition: all 0.3s ease;
        padding: 0 4px;
        background: transparent;
      }

      .neon-input:focus + .input-label,
      .neon-select:focus + .input-label,
      .ant-input-focused + .input-label {
        top: 0;
        font-size: 0.8em;
        color: #818cf8;
        background: rgba(30, 41, 59, 0.9);
      }
    }

    .neon-input, .neon-select {
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      transform-origin: center;

      &:focus {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(129, 140, 248, 0.5) !important;
      }
    }

    .cybr-btn {
      --primary: hsl(235, 86%, 65%);
      font-family: 'Oxanium', cursive;
      font-weight: 600;
      text-transform: uppercase;
      font-size: 1.1rem;
      letter-spacing: 1px;
      background: transparent;
      padding: 1em 2em;
      border: 2px solid var(--primary);
      color: var(--primary);
      transition: 0.2s;
      position: relative;
      overflow: hidden;
      cursor: pointer;

      &:hover {
        color: white;
        background: var(--primary);
        box-shadow: 0 0 25px var(--primary);

        .cybr-btn__glitch {
          display: block;
        }
      }

      &__glitch {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--primary);
        filter: drop-shadow(0 0 2px var(--primary));
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
        opacity: 0.3;
        animation: glitch-anim 0.3s infinite;
      }

      &__tag {
        position: absolute;
        right: 5%;
        bottom: 5%;
        font-size: 0.7em;
        opacity: 0.7;
      }
    }

    @keyframes glitch-anim {
      0% { transform: translateX(0); }
      20% { transform: translateX(-2px); }
      40% { transform: translateX(2px); }
      60% { transform: translateX(-1px); }
      80% { transform: translateX(1px); }
      100% { transform: translateX(0); }
    }

    // 标签选择器优化
    .neon-tags {
      .ant-select-selection-item {
        background: rgba(99, 102, 241, 0.15) !important;
        border: 1px solid #6366f1 !important;
        border-radius: 4px;
        color: #818cf8 !important;
        padding: 2px 8px !important;
        display: flex !important;
        align-items: center;

        &:hover {
          background: rgba(99, 102, 241, 0.3) !important;
        }

        .ant-select-selection-item-remove {
          color: #818cf8 !important;
          margin-left: 4px;
        }
      }
    }

    // 响应式优化
    @media (max-width: 768px) {
      .search-card {
        border-radius: 1rem;
        padding: 1.5rem;

        .search-title {
          font-size: 1.5rem;
        }
      }

      .cybr-btn {
        width: 100%;
        padding: 0.8rem;
        font-size: 1rem;
      }
    }
    .search-title {
      color: #e2e8f0;
      font-size: 1.8rem;
      text-align: center;
      position: relative;
      z-index: 1;
    }

    .search-subtitle {
      color: #94a3b8;
      text-align: center;
      margin-top: 0.5rem;
    }
  }
}

.search-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.neon-input, .neon-select, .neon-tags {
  background: rgba(15, 23, 42, 0.7) !important;
  border: 1px solid rgba(99, 102, 241, 0.3) !important;
  border-radius: 12px !important;
  color: #e2e8f0 !important;
  transition: all 0.3s ease;

  &:hover {
    border-color: #818cf8 !important;
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.2) !important;
  }

  &:focus {
    box-shadow: 0 0 20px rgba(129, 140, 248, 0.3) !important;
  }
}

.glow-button {
  position: relative;
  background: linear-gradient(45deg, #6366f1, #8b5cf6);
  border: none;
  padding: 0.8rem 2rem;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  overflow: hidden;
  transition: all 0.3s ease;

  .btn-text {
    position: relative;
    z-index: 2;
  }

  .hover-glow {
    position: absolute;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  &:hover {
    transform: translateY(-2px);

    .hover-glow {
      opacity: 1;
    }
  }
}

.data-table-card {
  background: rgba(30, 41, 59, 0.8);
  border-radius: 1.5rem;
  padding: 2rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(99, 102, 241, 0.2);

  .table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;

    .table-title {
      color: #e2e8f0;
      font-size: 1.4rem;
      font-weight: 600;
    }

    .table-count {
      color: #94a3b8;
      font-size: 0.9rem;
    }
  }
}

.modern-table {
  :deep(.ant-table-thead > tr > th) {
    background: linear-gradient(45deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    font-weight: 500;
    border: none !important;
  }

  :deep(.ant-table-tbody > tr) {
    background: rgba(15, 23, 42, 0.5);
    transition: all 0.3s ease;

    &:hover {
      background: rgba(99, 102, 241, 0.1) !important;
      transform: translateX(10px);
    }

    &:nth-child(even) {
      background: rgba(15, 23, 42, 0.3);
    }
  }

  :deep(.ant-table-cell) {
    color: #e2e8f0 !important;
    border-color: rgba(99, 102, 241, 0.2) !important;
  }
}

.image-preview {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;

  .preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
  }

  .image-hover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;

    .view-text {
      color: white;
      font-size: 0.8rem;
    }
  }

  &:hover {
    .preview-image {
      transform: scale(1.1);
    }

    .image-hover {
      opacity: 1;
    }
  }
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;

  .tag-item {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.3s ease;

    &:hover {
      background: rgba(99, 102, 241, 0.3);
      transform: translateY(-2px);
    }
  }
}

.info-grid {
  display: grid;
  gap: 8px;

  .info-item {
    display: flex;
    justify-content: space-between;

    .info-label {
      color: #94a3b8;
    }

    .info-value {
      color: #e2e8f0;
      font-weight: 500;
    }
  }
}

.action-buttons {
  display: flex;
  gap: 12px;

  .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: all 0.3s ease;
  }

  .edit-btn {
    color: #818cf8;

    &:hover {
      color: #6366f1;
      transform: rotate(15deg);
    }
  }

  .delete-btn {
    color: #f87171;

    &:hover {
      color: #ef4444;
      transform: scale(1.1);
    }
  }
}

.loading-overlay {
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  .loading-wave {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;

    .wave {
      width: 4px;
      height: 24px;
      background: #6366f1;
      animation: wave 1s ease-in-out infinite;

      &:nth-child(2) { animation-delay: 0.2s }
      &:nth-child(3) { animation-delay: 0.4s }
    }
  }

  .loading-text {
    color: #94a3b8;
  }
}

@keyframes wave {
  0%, 100% { transform: scaleY(1) }
  50% { transform: scaleY(1.5) }
}

@media (max-width: 768px) {
  .picture-management-container {
    padding: 1rem;
  }

  .search-card {
    padding: 1.5rem;
    border-radius: 1rem;
  }

  .search-form {
    grid-template-columns: 1fr;
  }
}
.preview-modal-image {
  width: 100%;
  height: 80vh;
  object-fit: contain;
  border-radius: 8px;
}

.review-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;

  .status-tag {
    flex-shrink: 0;
  }

  .review-detail {
    flex: 1;
    font-size: 12px;
    color: #e2e8f0;

    .review-message {
      color: #94a3b8;
      margin-top: 4px;
    }
  }
}

.action-buttons {
  .ant-btn {
    padding: 0 8px;
    height: 28px;
  }
}

@media (max-width: 768px) {
  .search-form {
    .ant-col {
      padding: 0 8px;
    }
  }

  .modern-table {
    :deep(.ant-table-thead > tr > th),
    :deep(.ant-table-tbody > tr > td) {
      padding: 12px 8px !important;
    }
  }
}
</style>
